#ifndef CONTROLPANEL_H
#define CONTROLPANEL_H

#include <QWidget>
#include <QModelIndex>
#include <QColorDialog>

#include "../DrawingElements/Dot.h"
#include "../Settings/GameSettings.h"
#include "../Controls/Delegate.h"

class QTableView;
class QStandardItemModel;
class QGroupBox;
class QStandardItem;
class QCheckBox;
class DotController;

class ControlPanel : public QWidget
{
Q_OBJECT
public:
    ControlPanel(QWidget *parent = 0);   

    bool aMomentBeforeClosing();

signals:

public slots:
    void playerItemDoubleClicked(const QModelIndex &index);
    void gameItemDoubleClicked(const QModelIndex &index);
    void playerItemChanged(QStandardItem *item);
    void gameItemChanged(QStandardItem *item);
    void cbPlayingWithComputerChanged(bool bChangedState);
    void gameStarted();
    void gameFinished(Game::Player player);
    void gameCanceled();
    void gameLevelChanged(bool bChecked);
    void networkGamePlayingViewInfoChanged(QString playerName,QColor color);
    void networkGameStartingParameterRequest(int nDotsPerRow, int nDotsPerColumn,QString playerName,QColor color);
    void netPlayBlockStateChanged(int nState);

protected slots:

private:
    QGroupBox *createNetworkGroupBox();
    QGroupBox *createPlayerGroupBox();
    QGroupBox *createGameGroupBox();
    QGroupBox *createComputerGroupBox();
    bool showColorDlg(QStandardItem *pItem);
    void initGameModelRow(int param,bool bColor);
    void setEnableItemsAtPlayingTime(bool bEnable);

private:
    QStandardItemModel *mpModelPlayer,*mpModelGame;
    QColorDialog mColorDlg;
    QGroupBox *mpGBPlayingWithComputer;
    QList<QStandardItem*> mItemsToDisableAtPlayingTime;
    SpinBoxDelegate *mpSpinboxDelegate;

};

#endif // CONTROLPANEL_H
